package com.guqj.thread.design;

public class ConsumerThread implements Runnable {

	private MyBlockQueue<String> queue;

	public ConsumerThread(MyBlockQueue<String> queue) {
		this.queue = queue;
	}

	@Override
	public void run() {
		try {
			int num = 0;
			while (num <= 100) {
				String task = queue.take();
				System.out.println("Consumer take task " + task);
				Thread.sleep((int) Math.random() * 100);
				num ++;
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
